package com.tonann.app.service.impl;

import com.tonann.app.domain.AppEnergyCaculatedRule;
import com.tonann.app.mapper.AppEnergyCaculatedRuleMapper;
import com.tonann.app.service.IAppEnergyCaculatedRuleService;
import com.tonann.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 运算规则Service业务层处理
 *
 * @author tonann
 * @date 2022-10-21
 */
@Service
public class AppEnergyCaculatedRuleServiceImpl implements IAppEnergyCaculatedRuleService {
    @Autowired
    private AppEnergyCaculatedRuleMapper appEnergyCaculatedRuleMapper;

    /**
     * 查询运算规则
     *
     * @param ruleId 运算规则主键
     * @return 运算规则
     */
    @Override
    public AppEnergyCaculatedRule selectAppEnergyCaculatedRuleByRuleId(Long ruleId) {
        return appEnergyCaculatedRuleMapper.selectAppEnergyCaculatedRuleByRuleId(ruleId);
    }

    /**
     * 查询运算规则列表
     *
     * @param appEnergyCaculatedRule 运算规则
     * @return 运算规则
     */
    @Override
    public List<AppEnergyCaculatedRule> selectAppEnergyCaculatedRuleList(AppEnergyCaculatedRule appEnergyCaculatedRule) {
        return appEnergyCaculatedRuleMapper.selectAppEnergyCaculatedRuleList(appEnergyCaculatedRule);
    }

    /**
     * 新增运算规则
     *
     * @param appEnergyCaculatedRule 运算规则
     * @return 结果
     */
    @Override
    public int insertAppEnergyCaculatedRule(AppEnergyCaculatedRule appEnergyCaculatedRule) {
        appEnergyCaculatedRule.setCreateTime(DateUtils.getNowDate());
        return appEnergyCaculatedRuleMapper.insertAppEnergyCaculatedRule(appEnergyCaculatedRule);
    }

    /**
     * 修改运算规则
     *
     * @param appEnergyCaculatedRule 运算规则
     * @return 结果
     */
    @Override
    public int updateAppEnergyCaculatedRule(AppEnergyCaculatedRule appEnergyCaculatedRule) {
        appEnergyCaculatedRule.setUpdateTime(DateUtils.getNowDate());
        return appEnergyCaculatedRuleMapper.updateAppEnergyCaculatedRule(appEnergyCaculatedRule);
    }

    /**
     * 批量删除运算规则
     *
     * @param ruleIds 需要删除的运算规则主键
     * @return 结果
     */
    @Override
    public int deleteAppEnergyCaculatedRuleByRuleIds(Long[] ruleIds) {
        return appEnergyCaculatedRuleMapper.deleteAppEnergyCaculatedRuleByRuleIds(ruleIds);
    }

    /**
     * 删除运算规则信息
     *
     * @param ruleId 运算规则主键
     * @return 结果
     */
    @Override
    public int deleteAppEnergyCaculatedRuleByRuleId(Long ruleId) {
        return appEnergyCaculatedRuleMapper.deleteAppEnergyCaculatedRuleByRuleId(ruleId);
    }
}
